package com.atyjh.reggie.mapper;

import com.atyjh.reggie.dto.DishDto;
import com.atyjh.reggie.entity.Dish;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author yjh
 * @since jdk1.8.0_311 2022.06.16
 */
@Mapper
public interface DishMapper extends BaseMapper<Dish> {

    /**
     * 多表查询，查出菜品已经对应的分类名称
     *
     * @param categoryId
     * @param dishId
     * @return DishDto类
     */
    @Select("SELECT * FROM `dish` LEFT JOIN `category` ON dish.category_id = category.id " +
            "where #{dishId} = dish.id AND #{categoryId} = category.id")
    DishDto queryDishWithCategoryName(@Param("categoryId") Long categoryId, @Param("dishId") String dishId);

}













